package com.woniuxy.controller;

import com.woniuxy.entity.Student;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: ideaAdmin
 * TODO:restFul风格
 * Date: 2022/1/25:16:51
 * Description:
 */

@RestController
@RequestMapping("rest")
public class RestFul {
    /**
     * @Author ideaAdmin
     * TODO:更新方法
     * @Date 16:56 2022/1/25
     * * @param id
     * * @return java.lang.String
     **/
    @RequestMapping(value = "/user/{id}",method = RequestMethod.PUT)
    public String updateUser(@PathVariable  int id){
        System.out.println("ResultFul.updateUser成功");
        return id+"";
    }

    /**
     * @Author ideaAdmin
     * TODO:del请求
     * @Date 16:56 2022/1/25
     * * @param id
     * * @return java.lang.String
     **/
    @DeleteMapping("/user/{id}")
    public String delUser(@PathVariable  int id){
        System.out.println("ResultFul.delUser");
        return id+"";
    }


    /**
     * @Author ideaAdmin
     * TODO:get请求 多个参数使用@PathVariable 可以用这个注解起别名
     * @Date 16:56 2022/1/25
     * * @param id
     * * @return java.lang.String
     **/
    @GetMapping ("/user/{id}/{username}")
    public String findUser(@PathVariable int id,@PathVariable String username){
        System.out.println("ResultFul.delUser成功");
        return id + "" + username;
    }

    /**
     * @Author ideaAdmin
     * TODO:post请求 @RequestBody对json对象做处理
     * @Date 17:16 2022/1/25
     * * @param student
     * * @return java.lang.String
     **/
    @PostMapping("/user")
    public String insertUser(@RequestBody  Student student){
        System.out.println("ResultFul.delUser成功");
        return student.toString();
    }


}
